home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_15831.txt < prev    next >
Text File  |  1991-02-27  |  2KB  |  32 lines

  1. -- card: 15831 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10.     struct Student:Person
  11.  
  12. No change has been made to the definition of the Person class*.  A new class has been defined, called Student.  The notation 'Student:Person' here indicates that the new class is DERIVED from the Person class.  (Since the Person class was itself defined with the 'indirect' specifier, the derived class is also indirect.)
  13.  
  14. A derived class ("child", "descendant", "subclass") is one which inherits the instance variables and methods of its base class ("parent", "ancestor").  In this case, any object of type Student will contain age and weight instance variables even if no such variables are explicitly declared in the definition of the Student class.  They are inherited from the Person class.
  15.  
  16. Likewise, if no set() or print() methods are defined in the Student class definition, a Student object will still accept set and print messages by accessing the methods defined for the Person class.  (In C++ the programmer must use the 'virtual' keyword in the base class declaration of these methods in order to enable the inheritance effect.)
  17.  
  18. -- part contents for background part 29
  19. ----- text -----
  20. 12751
  21.  
  22. -- part contents for background part 27
  23. ----- text -----
  24. Person class definition
  25.  
  26. -- part contents for background part 20
  27. ----- text -----
  28. Person class definition - p21
  29.  
  30. -- part contents for background part 7
  31. ----- text -----
  32. 42